home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / dinkum3 / dinkum.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  34.7 KB  |  1,239 lines

  1. #define DINKUM
  2. #include "dink_sym.h"
  3. #include "dink_glb.h"
  4. #include <stdlib.h>
  5.  
  6. /* ---------------- Version Date --------------- */
  7. char *lb_date = "22 February 1993" ;
  8. /* --------------------------------------------- */
  9.  
  10. /*  ---- Version Number  ---- */
  11. char *lb_version = "2.13" ;
  12. /*  ------------------------- */
  13.  
  14. /* ---------------- Version Type --------------- */
  15. char *lb_share = "[SOURCES.GAMES Version]" ;
  16. /* --------------------------------------------- */
  17.  
  18. /*  ---- Serial Number  ---- */
  19. #define S_number     1
  20. int serial = S_number ;
  21. /*  ------------------------ */
  22.  
  23. /* Global variables local to this file only */
  24. int sw_help = FALSE, sw_null = FALSE, sw_number = FALSE, sw_standard = FALSE ;
  25.  
  26. /* MAIN PROGRAM --- MAIN PROGRAM --- MAIN PROGRAM --- MAIN PROGRAM */
  27. #if (PROTOTYPE)
  28. int main(int argc, char *argv[])
  29. #else
  30. int main(argc,argv)
  31. int argc ;
  32. char *argv[] ;
  33. #endif
  34. /*********************************************************************/
  35. /*                                                                   */
  36. /*                   --- The Dinkum Program ---                      */
  37. /*                                                                   */
  38. /* Software by Gary A. Allen, Jr. 22 February 1993 Version: Mk 2.13  */
  39. /*            (c) Copyright 1993 by Gary A. Allen, Jr.               */
  40. /*                                                                   */
  41. /*********************************************************************/
  42. {
  43. register int i, j ;
  44.  
  45. int dig_1, dig_2, sw_loop ;
  46. int move_dir, i_rand1, i_rand2, i_rand3, loc[3] ;
  47. long l_pass, l_base, *time_arg = 0 ;
  48. char chr, cmd[8] ;
  49.  
  50. MONSTER_STRUCT *mnstr ;
  51. OBJECT_STRUCT *pnt ;
  52.  
  53. #if (PROTOTYPE)
  54. /* Function prototypes ANSI C */
  55. void cmd_switch(char[8], int, int, char *[]) ;
  56. void bugs(int), help(void), locker(int) ;
  57. void kelly(int), long_descp(int), objlooker(int), killer(int) ;
  58. void gleeper(int), actor(int), ender(int), closer(int), opener(int) ;
  59. void dialer(int), taker(int), dropper(int), describe(int) ;
  60. void igniter(int), switcher(int), unlocker(int), sounder(int) ;
  61. void loader(void), eater(void), filler(void), looker(int) ;
  62. void monster(int[3]), new_score(void), boom(void), parse(void) ;
  63. int mover(int,int[3]) ; 
  64. int yes_no(void) ;
  65. void inventer(void), drinker(void), reader(int), pusher(int*);
  66. void cheater(void) ; 
  67. void pass(void), unloader(int) ;
  68. long time(long*) ;
  69. char getch(void), getche(void) ;
  70. OBJECT_STRUCT* point_to_object(int) ;
  71.  
  72. #else
  73. /* Function prototypes K&R-C */
  74. int mover() ; 
  75. int yes_no() ;
  76. long time() ;
  77. char getch(), getche() ;
  78. OBJECT_STRUCT* point_to_object() ;
  79. #endif
  80.  
  81. /* Software security */
  82. if (serial != S_number) return(0) ;  /* abort if serial number changed */
  83.  
  84. /* Load the object pointers */
  85. Rifle = point_to_object(V_rifle) ;
  86. Teapot = point_to_object(V_teapot) ;
  87. Can = point_to_object(V_can) ;
  88. Clip = point_to_object(V_clip) ;
  89. Org_clip = point_to_object(V_org_clip) ;
  90. Recorder = point_to_object(V_recorder) ;
  91. Cap = point_to_object(V_cap) ;
  92. Dynamite = point_to_object(V_dynamite) ;
  93. Letter = point_to_object(V_letter) ;
  94. Clapper = point_to_object(V_clapper) ;
  95. Detector = point_to_object(V_detector) ;
  96. Key = point_to_object(V_key) ;
  97. Umbrella = point_to_object(V_umbrella) ;
  98. Matches = point_to_object(V_matches) ;
  99. Pills = point_to_object(V_pills) ;
  100. Cube = point_to_object(V_cube) ;
  101. Torch = point_to_object(V_torch) ;
  102. Mat = point_to_object(V_mat) ;
  103. Map = point_to_object(V_map) ;
  104. Map_frag = point_to_object(V_map_frag) ;
  105. Bottle = point_to_object(V_bottle) ;
  106. Circuit_breaker = point_to_object(V_circuit) ;
  107. Lift = point_to_object(V_lift) ;
  108. Door = point_to_object(V_door) ;
  109. Safe = point_to_object(V_safe) ;
  110. Lift_door = point_to_object(V_lift_door) ;
  111. Picture = point_to_object(V_picture) ;
  112. Tank = point_to_object(V_tank) ;
  113. Gong = point_to_object(V_gong) ;
  114. Transporter = point_to_object(V_transporter) ;
  115.  
  116. /* Scan the after the DOS/Unix command for switches or file name */
  117. if (argc > 1) {
  118. for (i = 1; i <= argc-1; i++) {
  119.     /* Flush command vector */
  120.     for (j = 0; j <= 7; j++) cmd[j] = '\0' ;
  121.     /* Get command vector */
  122.     sscanf(argv[i],"%c%c%c%c%c%c%c%c%c", &chr, &cmd[0], &cmd[1],
  123.         &cmd[2], &cmd[3], &cmd[4], &cmd[5], &cmd[6], &cmd[7]) ;
  124.     sw_null = FALSE ;
  125.     if (chr == '?') help() ;
  126.     if (chr == '-') {
  127.         for (j = 0; j <= 7; j++) {
  128.             cmd_switch(cmd, j, i, argv) ;
  129.             if (sw_number) {
  130.                 i++ ;
  131.                 sw_number = FALSE ;
  132.                 break ;
  133.             }
  134.             if (sw_null) break ;
  135.         } /* end of command "for" loop */
  136.  
  137.         if (j > 7) {
  138. printf("\n!!!! Too many commands on one \"-\" switch group.\n") ;
  139. printf("!!!! Break up the commands into several \"-\" switch groups.\n") ;
  140.             bugs(Failed) ;
  141.         }  
  142.     } /* end of the "-" marker block */
  143.  
  144.     /* Deal with garbage on the command line */
  145.     else {
  146. printf ("\n!!!! The following on the command line was not understood:  %s \n",
  147.     argv[i]);
  148.         bugs(Failed) ;
  149.     } /* Nondefault scratch file opening block */
  150.  
  151. } /* end of argument token "for" loop */
  152.  
  153. if (sw_help) help() ;
  154. } /* end of the command switch block */
  155.  
  156. /* Deal with someone cheating with switch "-s" */
  157. if (sw_standard && (!sw_wizard)) {
  158.     printf("!!!! Command line switch -s is unknown.\n") ;
  159.     bugs(Failed) ;
  160. }
  161.  
  162. /* Software security */
  163. if (serial != S_number) return(0) ;  /* abort if serial number changed */
  164.  
  165. /* Initialize the program */
  166. sw_warned = FALSE ;
  167. l_time = time(time_arg) ;
  168. l_base = l_time/10 ;
  169. l_base *= 10 ;
  170. l_pass = l_time - l_base ;
  171. dig_1 = (int)l_pass ;
  172. loc[2] = 0 ;     /* zero out the "old" location */
  173.  
  174. printf("                    ") ;
  175. printf("                   --- Dinkum --- \n");
  176. printf("                    ") ;
  177. printf("     (c) Copyright 1993 by Gary A. Allen, Jr.\n") ;
  178. printf("                    ") ;
  179. printf("  All Rights Reserved. Version %s, %s\n\n",
  180.     lb_version, lb_date);
  181.  
  182. printf("Would like some initial help with Dinkum?\n") ;
  183.  
  184. if (yes_no()) {
  185. printf("\nG'day Mate!  Welcome to \"Dinkum\" the Australian adventure");
  186. printf("\ngame.  In Dinkum you'll search for treasure in the\n") ;
  187. printf("Australian Outback.  You give the commands and I'll do the\n");
  188. printf("dangerous work. I understand most plain English sentences.\n");
  189. printf("If you want me to go east then type \"Will you please go\n");
  190. printf("east?\" and press the RETURN or ENTER key.  If you don't\n") ;
  191. printf("enjoy typing then just type \"e\" and press RETURN.  I'll\n");
  192. printf("still go east.  After you have gathered up some things\n") ;
  193. printf("you can see what you have by typing \"inventory\".\n") ;
  194. printf("Sometimes you can learn more about an object by typing\n");
  195. printf("\"examine NAME-OF-OBJECT\".  I understand many other\n") ;
  196. printf("commands and words.  However I'll let you have the fun of\n") ;
  197. printf("finding out what I can and can not understand. Good luck!\n\n");
  198. }
  199.  
  200. /* produce two random numbers ranging from 0-9 based on system clock*/
  201. l_time = time(time_arg) ;
  202. start_time = l_time ;
  203. l_base = l_time/10 ;
  204. l_base *= 10 ;
  205. l_pass = l_time - l_base ;
  206. dig_2 = (int)l_pass ;
  207.  
  208. /* generate the actual random array pointers */
  209. if (sw_standard) {
  210.     i_rand1 = 2 ; 
  211.     i_rand2 = 3 ;
  212.     i_rand3 = 1 ;
  213. }
  214. else {
  215.     i_rand3 = (dig_1 + dig_2)/2 ;
  216.     i_rand2 = dig_2/3 ;
  217.     i_rand1 = (dig_1/3) + 1 ;
  218. }
  219.  
  220. printf("\nIt's a hot summer day (in January) in ") ;
  221. printf("Queensland, Australia.\n") ;
  222. loc[1] = R_meadow ;
  223. loc[0] = R_meadow ;
  224.  
  225. /* Software security */
  226. if (serial != S_number) return(0) ;  /* abort if serial number changed */
  227.  
  228. /* load objects into the rooms */
  229. if (Gong->Status == S_recorder) Recorder->Location = R_meadow ;
  230. pnt = object ;
  231. for (j = 0; j < Objcnt; j++) {
  232.     for (i = 0; i < Obj_init_max; i++) {
  233.         if (pnt->ID == obj_init[i][0]) {
  234.             pnt->Location = obj_init[i][i_rand1] ;
  235.             break ;
  236.         }
  237.     }
  238.     i = pnt->Location ;
  239.  
  240.     /* Flag the presence of unmovable objects in each room */
  241.         if (pnt->Type == Z_unmovable) room[i][M_unmov_obj] = TRUE ; 
  242.  
  243.     /* Count up number of movable objects in each room */
  244.     else if (i >= 0) ++room[i][M_obj_cnt] ;
  245.     
  246.     pnt++ ;
  247. }
  248.  
  249. carry_count = 0 ;
  250. carry_weight = 0 ;
  251.  
  252. /* Initialize the Monsters */
  253. if ((monster_start = (MONSTER_STRUCT *)calloc((unsigned)(Enemy_cnt+1),
  254.         sizeof(MONSTER_STRUCT))) == 0) {
  255.     printf("\n---- PROBLEMS ----\n") ;
  256.     printf("RAM memory is full!\n") ; 
  257.     printf(" PROGRAM ABORTED\n") ;
  258.     return(0) ;
  259. }
  260.  
  261. Ned = (monster_start + N_ned) ;        /* point to the Ned Kelly structure */
  262. Guards = (monster_start + N_guards) ;  /* point to the Guards structure */
  263. Wombat = (monster_start + N_wombat) ;  /* point to the Wombat structure */
  264. Mullah = (monster_start + N_mullah) ;  /* point to the Mullah structure */
  265.  
  266. /* Load up the monster data structure */
  267. for (i = 0; i <= Enemy_cnt; i++) { 
  268.     mnstr = (monster_start + i) ;     /* point to the monster */
  269.  
  270.      /* locate the monster */
  271.     if (i == 0) mnstr->Location = B_unmade ;
  272.     else mnstr->Location = mon_init[i-1][i_rand2] ;
  273.  
  274.     /* All monsters are initially asleep */
  275.     mnstr->Status = F_asleep ;
  276.  
  277.     /* Load Type numbers for the different monsters */
  278.     switch(i) {
  279.     case 2:
  280.     case 3:
  281.     case 4:
  282.     case 5:
  283.         mnstr->Type = N_drop_bear ;
  284.         break ;
  285.     case 6:
  286.     case 7:
  287.     case 8:
  288.     case 9:
  289.     case 10:
  290.     case 11:
  291.     case 12:
  292.     case 13:
  293.         mnstr->Type = N_hoop_snake ;
  294.         break ;
  295.     default:
  296.         mnstr->Type = i ;
  297.     } /* end of the monster Type switch block */
  298.  
  299.     /* Monsters are initially healthy */
  300.     mnstr->Hits = 0 ;    
  301.  
  302.     j = mnstr->Location ;
  303.     if (j != B_unmade) ++room[j][M_monster] ;
  304. } /* end of the monster data structure loadup "for" loop */
  305.  
  306. /* load the gleep reproductive locations and seed gleep */
  307. for (i = 0; i <= 9; i++)  
  308.     gleep_spot[i] = gleep_init[i][i_rand2] ;
  309. room[gleep_spot[0]-1][M_gleep] = 1 ; /* seed a nonreproductive spot */ 
  310.  
  311. /* load safe passage for end-game killing passages  */
  312. room[218 + i_rand3][M_rm_type] = T_short_descp ;
  313.  
  314. /* Beginning of outer infinite "for" loop */
  315. for(;;) {
  316. /* special action routine */
  317. new_score() ;  /* update the score */
  318.  
  319. /* See if the game has timed out */
  320. l_time = time(time_arg) ;
  321. if ((!sw_warned) && (l_time > start_time + 3300L)) {
  322.     sw_warned = TRUE ;
  323.     start_time = l_time ;
  324. printf("There's suddenly a puff of blue smoke which fills the room\n") ;
  325. printf("with a hazy cloud.  Slowly this cloud coalesces into a\n") ;
  326. printf("ghostly human form.  This ethereal being is wearing a grey\n") ;
  327. printf("flannel suit, a bowler hat, and glancing at a gold pocket\n") ;
  328. printf("watch which is attached to a long golden chain.  You can\n");
  329. printf("hear \"Waltzing Matilda\" being played softly in the\n") ;
  330. printf("background.  You know what?  I think this ethereal being\n") ;
  331. printf("is none other than the ghost of Banjo Patterson!  With\n") ;
  332. printf("this realization Banjo looks up in your direction and\n") ;
  333. printf("begins to speak:\n\n") ;
  334. printf("\"Sorry mate, you've been at this for too long!  You've\n") ;
  335. printf("got five more minutes to go and then you're history!\"\n\n") ;
  336. printf("Then just as suddenly Banjo Patterson dissolves back into\n") ;
  337. printf("smoke and disappears from view.\n\n") ;
  338. }
  339. if (sw_warned && (l_time > start_time + 300L)) {
  340. printf("You hear someone clearing his throat behind you.  You turn\n") ;
  341. printf("around and see Banjo Patterson has appeared once again.  An\n");
  342. printf("old brass chain is hanging from mid air next to Banjo.  On\n") ;
  343. printf("the end of the chain is a white porcelain tear drop shaped\n");
  344. printf("nob with the word \"PULL\" written on it in black letters.\n") ;
  345. printf("Banjo reaches for the nob and says the following:\n\n\"Sorry") ;
  346. printf(" mate, your time has come!  Better luck next time!\"\n\n");
  347. printf("He gives the chain a quick jerk and everything around you\n") ;
  348. printf("slowly fades from view.\n\n") ;
  349.     ender(F_quit) ;
  350. }
  351.  
  352. kelly(loc[0]) ; /* check if Ned Kelly can do something */
  353.  
  354. /* Check if there is a long description */
  355. if ((!((room[R_hideout][M_monster] > 0) && (loc[0] == R_hideout))) &&
  356.     (!((monster_flag == F_monster_active) && (loc[2] == loc[0])))) {
  357.  
  358.     loc[2] = 0 ;
  359.  
  360. /* Check if there is to be a long room description */
  361. if (room[loc[0]][M_rm_type] == T_long_descp) long_descp(loc[0]) ;
  362. else {
  363.     describe(loc[0]) ;  /* short description */
  364.  
  365.     /* describe unmovable action objects and status */
  366.     if (room[loc[0]][M_unmov_obj]) actor(loc[0]) ;
  367. }
  368.  
  369. objlooker(loc[0]) ; /* Check if there are objects in the room */
  370. gleeper(loc[0]) ;   /* check for gleeps and update the gleep count */
  371.  
  372. /* see if the spaceship's transporter is active */
  373. if (Transporter->Status) {
  374.     if (loc[0] == R_ship_passage) Transporter->Status = FALSE ;
  375.     else if (loc[0] == R_transporter) {
  376.         loc[0] = R_closet ;
  377.         Transporter->Status = FALSE ;
  378. printf("\nSuddenly radiant energy seems to surge from the hexagons\n");
  379. printf("around you.  Then there is a bright flash and you find\n");
  380. printf("yourself in.....\n\n") ;
  381. printf("A closet stinking of moth balls full of nondescript junk.\n") ;
  382. printf("The only exit is to the north through a curtain hanging\n");
  383. printf("over the entrance.\n\n") ; 
  384.     }
  385. } /* end of the "transporter" block */
  386. } /* end of long description check block */
  387.  
  388. for(;;) {
  389. sw_loop = FALSE ;
  390.  
  391. /* monster check */
  392. if ((room[loc[0]][M_monster] > 0)||(monster_flag != F_no_monster)) {
  393.     if (monster_flag == F_wounded) monster_flag = F_monster_active ;
  394.     else monster(loc) ;
  395. } /* end of the monster check block */
  396.  
  397. /* parse in the command */
  398. parse();
  399.  
  400. /* poison check */
  401. /* remove atropine drug with each game cycle */
  402. if (i_poison > 0) --i_poison ;
  403. else {
  404.     /* accumulate poison if holding the orange clip */
  405.     if (Org_clip->Location == B_have) {
  406.         --i_poison ;
  407.         switch (i_poison) {
  408.         case -20:
  409.     printf("You've developed a nervous tick near your eye.\n") ;
  410.             break ;
  411.         case -30:
  412.     printf("You're hands are starting to shake ") ;
  413.     printf("and you're sweating like a pig.\n") ;    
  414.             break ;
  415.         case -35:
  416.     printf("You're shaking so bad you can barely stand and you ");
  417.     printf("could lose your lunch\nat any moment.\n") ;
  418.             break ;
  419.         case -40:
  420. printf("The toxic fumes coming off of the orange ammo clip you were ") ;
  421. printf("carrying finally\ncaught up with you.  You fall over DEAD!\n") ;
  422.             ender(F_died) ;
  423.         }
  424.     }
  425.     /* remove poison after release of orange clip */
  426.     else if (i_poison < 0) ++i_poison ;
  427. } /* end of the poison check block */
  428.  
  429. /* clock check */
  430. if (sw_clock) {
  431.     switch (flag_clock) {
  432.     /* see if the blasting cap is to explode */
  433.     case V_cap:
  434.         if (time(time_arg) > clock_explode) {
  435.             if (Cap->Location == B_have) {
  436. printf("                           POP!!\n") ;
  437. printf("The blasting cap which you were stupidly holding in your\n") ;
  438. printf("hand just blew up and took two of your fingers with it!\n") ;
  439. printf("Good thing you've got another eight fingers to spare!\n\n") ;
  440.                 carry_count-- ;
  441.                 carry_weight -= Cap->Weight ;
  442.             }
  443.             else {
  444. printf("Far down the tunnel you hear a POP!\n") ;
  445. printf("The blasting cap has finally exploded, not that it\n");
  446. printf("achieved much except make a loud noise.\n\n") ;
  447.             }
  448.             Cap->Location = B_destroyed ;
  449.             sw_clock = FALSE ;
  450.         }
  451.         break ;
  452.     
  453.     /* see if the dynamite is to explode */
  454.     case V_dynamite:
  455.         if (time(time_arg) > clock_explode) {
  456.             /* player dies if he is holding the dynamite */
  457.             if (Dynamite->Location == B_have) {
  458.             boom() ;
  459.  
  460. printf("The dynamite which you were holding and had earlier ignited\n");
  461. printf("the fuse has finally exploded.  That was a rather noisy\n");
  462. printf("and messy way to commit suicide!  Needless to say there is\n");
  463. printf("nothing left of you but a greasy spot.\n") ;
  464.             ender(F_died) ;
  465.             }
  466.             /* player dies if too close during explosion */
  467.             else {
  468.                 if (((loc[0] <= 185) && (loc[0] >= 178))
  469.                   || ((loc[0] <= 170) && (loc[0] >= 166))) {
  470.                     boom() ;
  471.  
  472. printf("You weren't far enough away from the dynamite when it\n");
  473. printf("exploded!  The shock wave was still strong enough to blow\n");
  474. printf("your brains out your ears.  Next time try to get to the\n") ;
  475. printf("upper level before the dynamite goes off.\n") ;
  476.                     ender(F_died) ;
  477.                 }
  478.  
  479.                 /* dynamite explodes and player survives */
  480.                 else {
  481. printf("Far down the tunnel you hear a low BOOM!\n") ;
  482. printf("That dynamite you set burning has finally exploded.\n\n");
  483.  
  484. /* open up the passage to the UFO */
  485. if (Dynamite->Location == R_blast_point) {
  486.     room[R_blast_point][1] = 186 ;
  487.     room[R_blast_point][M_descp] = 55 ;
  488.                     }
  489.                 }
  490.             }
  491.             Dynamite->Location = B_destroyed ;
  492.             sw_clock = FALSE ;
  493.         } /* end of the dynamite explodes block */
  494.         break ;
  495.     }
  496. } /* end of the clock block */
  497.  
  498. /* the command is a simple move command */
  499. if (tag[V_MOVE]) {
  500.     if (mover(verb,loc)) break ;
  501.     continue ;
  502. } /* end of the "move" block */
  503.  
  504. /* complicated command decoder */
  505. switch (verb) {
  506.  
  507. /* "help" command */
  508. case V_help:
  509. case V_info:
  510. printf("There is no help available.  You're on your own!\n") ;
  511.     break ;
  512.  
  513. /* "quit" command */
  514. case V_quit:
  515.     ender(F_quit) ;
  516.  
  517. /* "question" command */
  518. case V_QUESTION:
  519.     if (tag[V_VERB_ONLY]) {
  520.         if (tag[V_how]) {
  521. printf("That's for you to figure out.\n") ;
  522.             break ;
  523.         }
  524. printf("I don't have a clue!\n") ;
  525.         break ;
  526.     }
  527.  
  528.     /* Question "Where am I?" */
  529.     if (tag[V_where] && tag[V_am]) {
  530.         tag[V_VERB_ONLY] = TRUE ; /* This is for "looker" */
  531.         looker(loc[0]) ;
  532.         break ;
  533.     }
  534.  
  535.     /* Question "What have I got?" */
  536.     if (tag[V_what] && tag[V_have]) {
  537.         inventer() ;
  538.         break ;
  539.     }
  540.  
  541.     /* Question which can't be processed */
  542. printf("You asked a question.  Unfortunately I have no answers.\n") ;
  543.     break ;
  544.  
  545. /* "inventory" command */
  546. case V_inventory: 
  547. case V_invent:
  548.     inventer() ;
  549.     break;
  550.  
  551. /* "close" command  */
  552. case V_close:
  553. case V_shut:
  554.     closer(loc[0]) ;
  555.     break;
  556.  
  557. /* "open" command  */
  558. case V_open:
  559. case V_swing:
  560.     opener(loc[0]) ;
  561.     break;
  562.  
  563. /* "dial" command  */
  564. case V_dial:
  565. case V_combination:
  566.     dialer(loc[0]) ;
  567.     break ;
  568.  
  569. /* "drink" command */
  570. case V_drink: 
  571.     drinker() ;
  572.     break ;
  573.  
  574. /* "ignite" command */
  575. case V_ignite: 
  576. case V_light: 
  577.     igniter(loc[0]) ;
  578.     break ;
  579.  
  580. /* "read" command  */
  581. case V_read:
  582.     reader(loc[0]) ;
  583.     break;
  584.  
  585. /* "push" command  */
  586. case V_push:
  587. case V_press:
  588.     pusher(&loc[0]) ; 
  589.     break ;
  590.  
  591. /* "turn", "switch" command */
  592. case V_switch:
  593. case V_turn:
  594. case V_select:
  595. case V_set:
  596.     switcher(loc[0]) ;
  597.     break ;
  598.  
  599. /* "shoot" command  */
  600. case V_shoot:
  601. case V_fire:
  602. case V_kill:
  603.     killer(loc[0]) ;
  604.     break;
  605.  
  606. /* "unlock" command  */
  607. case V_unlock:
  608.     unlocker(loc[0]) ;
  609.     break;
  610.  
  611. /* "lock" command  */
  612. case V_lock:
  613.     locker(loc[0]) ;
  614.     break;
  615.  
  616. /* "eat" command  */
  617. case V_eat:
  618. case V_swallow:
  619.     eater() ;
  620.     break;
  621.  
  622. /* "fill" command  */
  623. case V_fill:
  624.     filler() ;
  625.     break;
  626.  
  627. /* "sound" command  */
  628. case V_sound:
  629. case V_bang:
  630. case V_hit:
  631. case V_strike:
  632.     sounder(loc[0]) ;
  633.     break;
  634.  
  635. /* "SVC" wizard move command */
  636. /* This command had an error in it discovered by Per-Anders Eriksson. */
  637. /*      Thanks, Per-Anders!                                           */
  638. case V_svc:
  639.     if (sw_wizard) {
  640.         printf ("Enter room coordinate number:  ");
  641.         scanf ("%d",&loc[0]);
  642.         monster_flag = F_no_monster ; /* turn off monsters */
  643.         sw_loop = TRUE ;
  644.         break ;
  645.     }
  646.     else cheater() ;
  647.  
  648. /* "STATS" game statistics */
  649. case V_stats :
  650.         printf("      --- Dinkum --- \n");
  651.         printf("Version: %s, %s\n\n", lb_version, lb_date);
  652.         printf("i_rand1 = %d, i_rand2 = %d, i_rand3 = %d\n",
  653.             i_rand1, i_rand2, i_rand3) ;
  654.         printf("Room Number = %d\n", loc[0]) ;
  655.         printf("Room object count = %d \n",
  656.             room[loc[0]][M_obj_cnt]) ;
  657.         printf("Room monster count = %d\n",
  658.             room[loc[0]][M_monster]) ; 
  659.         printf("Gleeps on room's floor count = %d\n",
  660.             room[loc[0]][M_gleep]) ;
  661.         printf("Poison level = %d\n",i_poison) ;
  662.         printf("Gleep count = %d\n", gleep_count) ;
  663.         printf("carry_count = %d, carry_weight = %d\n",
  664.             carry_count, carry_weight) ;
  665.         break ;
  666.  
  667. /* "SU" wizard initiation command */
  668. case V_su:
  669.     pass() ;
  670.     break ;
  671.  
  672. /* "JSYS" wizard command which deactivates a monster */
  673. case V_jsys:
  674.     if (sw_wizard) monster_flag = F_no_monster ;
  675.     else cheater() ;
  676.     break ;
  677.  
  678. /* "score" command */
  679. case V_score: 
  680.     new_score() ;
  681.     if ((Tank->Status == 0)&&(score == 0)) {
  682. printf("You haven't scored anything at all, Bozo! Try putting\n");
  683. printf("a valuable into the safe or find some gleeps.\n") ;
  684.         break ;
  685.     }
  686.     if (score == 0) { 
  687.         if (Tank->Status > 1) {
  688. printf("You haven't scored any points but you splashed ") ;
  689. printf ("%d gleeps into the gleep tank.\n",Tank->Status) ;
  690.         }
  691.         else {
  692. printf("You haven't scored any points at all but you did put a\n");
  693. printf ("gleep in the gleep tank (big deal!).\n") ;
  694.         }
  695.     }
  696.     else {
  697. printf ("You scored %d points ",score) ;
  698.         if (Tank->Status == 0) 
  699. printf ("but have yet to put any gleeps in the gleep tank.\n") ;
  700.         else {
  701.             if (Tank->Status > 1) 
  702. printf ("and put %d gleeps into the gleep tank.\n",Tank->Status) ;
  703.     
  704.             else 
  705. printf ("and put a gleep in the gleep tank.\n") ;
  706.         }
  707.     }
  708.     break ;
  709.  
  710. /* "enter" command  */
  711. case V_enter:
  712. switch (loc[0]) {
  713.  
  714.     /* Lift entrance at the ground level */
  715.     case R_lift_entr:
  716.         if (room[R_lift_entr][2] == R_WALL) {
  717. printf("I can't do it!  The lift door needs to be opened.\n") ;
  718.             continue ;
  719.         }
  720.         move_dir = V_east ;
  721.         break ;
  722.     /* office door */
  723.     case R_office_entr:
  724.         if (room[R_office_entr][2] == R_WALL) {
  725. printf("I can't go in!  The office door needs to be opened.\n") ;
  726.             continue ;
  727.         }
  728.         move_dir = V_east ;
  729.         break ;
  730.     /* Lift entrance at level #49 */
  731.     case R_L49_entr:
  732.         move_dir = V_east ;
  733.         break ;
  734.     /* Entrance to Ned Kelly's hideout */
  735.     case R_hideout_entr:
  736.         move_dir = V_east ;
  737.         break ;
  738.  
  739.     /* Enter gleep tank (and suicide) */
  740.     case R_gleep_tank:
  741.         if (tag[V_tank]) {
  742. printf("\nYou climb up onto the edge of the gleep tank and dip your\n");
  743. printf("foot into the dark blue fluid.  Suddenly the fluid begins a\n");
  744. printf("furious boiling that instantly reduces your foot into\n") ;
  745. printf("bleached white bones.  The shock and pain disturbs your\n");
  746. printf("balance and you fall into the horrible stuff!!  There is\n");
  747. printf("once again a furious boiling.  Eventually the fluid stills\n");
  748. printf("and becomes clear again.  On the bottom of the tank can\n") ;
  749. printf("be seen a white, clean, \"medical school quality\" human\n");
  750. printf("skeleton.\n") ;
  751.             ender(F_died) ;
  752.         }
  753.  
  754.     default:
  755.     printf("I don't understand exactly how to enter. \n");
  756.         continue ;
  757. } /* end of the "enter" switch block */
  758. if (mover(move_dir, loc)) sw_loop = TRUE ;
  759. break ;
  760.  
  761. /* "exit" command  */
  762. case V_exit:
  763. case V_leave:
  764. case V_depart:
  765. switch (loc[0]) {
  766.  
  767.     /* Lift entrance at the ground level */
  768.     case R_lift_inside:
  769.         move_dir = V_west ;
  770.         break ;
  771.     /* office door */
  772.     case R_office_hall:
  773.         move_dir = V_west ;
  774.         break ;
  775.     /* Ned Kelly's hideout */
  776.     case R_hideout :
  777.         move_dir = V_west ;
  778.         break ;
  779.     default:
  780. printf("I don't understand exactly how you want to exit.\n");
  781.         continue ;
  782. } /* end of the "depart" switch block */
  783. if (mover(move_dir, loc)) sw_loop = TRUE ;
  784. break ;
  785.  
  786. /* "dig" command */
  787. case V_dig:
  788. printf("You get on your knees and scrape away at the ground for\n") ;
  789. printf("awhile. Except for getting your hands dirty you didn't\n") ;
  790. printf("achieve much.\n") ;
  791.     break ;
  792.  
  793. /* "stand" command */
  794. case V_stand:
  795. printf("You're standing there very nicely.  However you're not\n");
  796. printf("achieving much by doing so.\n") ;
  797.     break ;
  798.  
  799. /* "load" rifle command */
  800. case V_load:
  801.     loader() ;
  802.     break ;
  803.  
  804. /* "unload" rifle command */
  805. case V_unload:
  806.     unloader(loc[0]) ;
  807.     break ;
  808.  
  809. /* "pull" command */
  810. case V_pull:
  811.     if (tag[V_trigger]) {
  812.         /* alias in the "shoot" command */
  813.         verb = V_shoot ;
  814.         tag[V_VERB_ONLY] = TRUE ;
  815.         killer(loc[0]) ;   /* "pull trigger" */
  816.     }
  817.     else  printf("I don't see how I could pull that.\n") ;
  818.     break ;
  819.  
  820. /* "climb" command */
  821. case V_climb:
  822. printf("I'm not climbing anything!  (I'm afraid of heights.)\n") ;
  823.     break ;
  824.  
  825. /* "swim" command */
  826. case V_swim:
  827. printf("I'm not going for a swim!  (I'm afraid of the water.)\n") ;
  828.     break ;
  829.  
  830. /* Go backwards to previous location */
  831. case V_back:
  832.     loc[0] = loc[1] ;
  833.     sw_loop = TRUE ;
  834.     break ;
  835.  
  836. /* "take", "get", "lift" command */
  837. case V_take:
  838. case V_get:
  839. case V_lift:
  840. case V_pick:
  841. case V_grab:
  842. case V_remove:
  843. case V_attach:
  844. case V_hold:
  845.     taker(loc[0]) ;
  846.     break ;
  847.  
  848. /* "drop", "throw", "put" command */
  849. case V_drop:
  850. case V_throw:
  851. case V_put:
  852. case V_fling:
  853. case V_toss:
  854. case V_insert:
  855. case V_give:
  856. case V_eject:
  857. case V_slow_drop:
  858.     dropper(loc[0]) ;
  859.     break ;
  860.  
  861. /* "look" command */
  862. case V_look:
  863. case V_view:
  864. case V_examine:
  865. case V_inspect:
  866. case V_describe:
  867.     looker(loc[0]) ;
  868.     break;
  869.  
  870. /* gibberish command */
  871. default:
  872. printf("Huh?  You will have to make yourself clearer! \n");
  873.  
  874. } /* end of "decoder" switch */
  875. if (sw_loop) break ;
  876. } /* end of the inner infinite "for" loop */
  877. } /* end of the outer infinite "for" loop */
  878.  
  879. } /* --- end of Main routine --- */
  880.  
  881. #if (PROTOTYPE)
  882. void cmd_switch(char cmd[8], int cmd_arg, int i_point, char *argv[])
  883. #else
  884. cmd_switch(cmd, cmd_arg, i_point, argv)
  885. char cmd[8], *argv[] ;
  886. int cmd_arg, i_point ;
  887. #endif
  888. /*****************************************************/
  889. /*                                                   */
  890. /*         --- Command line Switch Parser ---        */
  891. /*                                                   */
  892. /*  (c) Copyright 1992,   University of Queensland   */
  893. /*        Program written by Gary A. Allen, Jr.      */
  894. /*           Version:  Mk 1.1   24 February 1992     */
  895. /*                                                   */
  896. /*****************************************************/
  897. {
  898.  
  899. #if (PROTOTYPE)
  900. void bugs(int), pass(void) ;
  901. #endif
  902.  
  903. switch (cmd[cmd_arg]) {
  904. case '\0':
  905. case -1:
  906.     sw_null = TRUE ;
  907.     return ;
  908.  
  909. /* Activate save script capability */
  910. case 's':
  911. case 'S':
  912.     Gong->Status = S_recorder ;
  913.     break ;
  914.  
  915. /* Version verification command switch */
  916. case 'v':
  917.     if ((cmd[cmd_arg+1] == 'e')&&(cmd[cmd_arg+2] == 'r')) {
  918.         printf("Version: %s, Serial Number: %06d %s \n", 
  919.             lb_version, serial, lb_share) ;
  920.         bugs(Request) ;
  921.     }
  922.     else {
  923.         printf("!!!! Command line switch -v is unknown.\n") ;
  924.         bugs(Failed) ;
  925.     }
  926.  
  927. /* Wizard mode command switch */
  928. case 'w':
  929. case 'W':
  930.     pass() ;
  931.     break ;
  932.  
  933. /* Standard matrix load command switch */
  934. case 'x':
  935. case 'X':
  936.     sw_standard = TRUE ;
  937.     break ;
  938.  
  939. /* Rubbish option to supress a warning */
  940. case 'y':
  941. case 'Y':
  942.     sw_number = TRUE ;
  943.     printf("y = %d\n", atoi(argv[i_point+1])) ;
  944.     return ;
  945.  
  946. /* Help option */
  947. case '?':
  948. case 'h':
  949. case 'H':
  950.     sw_help = TRUE ;
  951.     return ;
  952.  
  953. case ' ':
  954. case '-':
  955. case '1':
  956. case '2':
  957. case '3':
  958. case '4':
  959. case '5':
  960. case '6':
  961. case '7':
  962. case '8':
  963. case '9':
  964.     return ;
  965.  
  966. default:
  967. printf("!!!! Command line switch -%c is unknown.\n", cmd[cmd_arg]) ;
  968.     bugs(Failed) ;
  969. }
  970. } /* --- end of the cmd_switch subroutine --- */
  971.  
  972. #if (PROTOTYPE)
  973. void bugs(int i_type)
  974. #else
  975. bugs(i_type)
  976. int i_type ;
  977. #endif
  978. /***************************************************************/
  979. /*                                                             */
  980. /*       (c) Copyright 1992,   University of Queensland        */
  981. /*            Program written by Gary A. Allen, Jr.            */
  982. /*             Version:  Mk 1.0        24 April 1992           */
  983. /*                                                             */
  984. /***************************************************************/
  985. {
  986. switch(i_type) {
  987. case Failed:
  988.     printf("!!!! If confused, type:  dinkum -h \n");
  989.     printf("!!!! --- Program ABORTED --- \n");
  990.     break ;
  991.  
  992. case Request:
  993.     printf("Program terminated by user request.\n") ;
  994.     break ;
  995.  
  996. case Logic_error:
  997.     printf("Please refer to program author's address by typing\n") ;
  998.     printf("\"dinkum -h\" and inform the author of this error.\n") ;
  999.     printf("             --- Program ABORTED ---\n") ;
  1000.     break ;
  1001. }
  1002. exit(0) ; 
  1003. } /* --- end of the "bugs" subroutine --- */
  1004.  
  1005. #if (PROTOTYPE)
  1006. void help(void) 
  1007. #else
  1008. help() 
  1009. #endif
  1010. /*****************************************************/
  1011. /*                                                   */
  1012. /*                    Help Routine                   */
  1013. /*                                                   */
  1014. /*  (c) Copyright 1992,   University of Queensland   */
  1015. /*        Program written by Gary A. Allen, Jr.      */
  1016. /*           Version:  Mk 1.0    24 April 1992       */
  1017. /*                                                   */
  1018. /*****************************************************/
  1019. {
  1020. char chr ;
  1021.  
  1022. printf("                    --- Dinkum --- \n");
  1023. printf("       (c) Copyright 1993 by Gary A. Allen, Jr.\n") ;
  1024. printf("   All Rights Reserved. Version: %s, %s\n\n", 
  1025.         lb_version, lb_date);
  1026.  
  1027. printf("      Dinkum is a text style \"adventure\" game.\n\n") ;
  1028.  
  1029. printf("You are free to use, copy and distribute Dinkum provided:\n") ;
  1030. printf("       NO FEE IS CHARGED FOR USE, COPYING OR DISTRIBUTION.\n") ;
  1031. printf("       THIS PROGRAM IS FOR PRIVATE, NONCOMMERICAL USE ONLY.\n");
  1032. printf("       THE PROGRAM MAY NOT BE MODIFIED IN ANY WAY.\n\n") ;
  1033.  
  1034. printf("This program is provided AS IS without any warranty,\n") ;
  1035. printf("expressed or implied, including but not limited to fitness\n") ;
  1036. printf("for any particular purpose.\n\n") ;
  1037.  
  1038. /* keep the screen from scrolling */
  1039. #ifndef __TURBOC__
  1040. printf("         [Press RETURN or ENTER to continue]") ;
  1041. chr = getchar() ;
  1042. #endif
  1043.  
  1044. #ifdef __TURBOC__
  1045. printf("  [Press \"q\" to quit or any other key to continue]") ;
  1046. chr = getche() ;
  1047. printf("\r                                                        \r") ;
  1048. #endif
  1049.  
  1050. if ((chr == 'q')||(chr == 'Q')) exit (0) ;
  1051.  
  1052. printf("If you start the game by typing \"dinkum -s\" rather than \n");
  1053. printf("simply \"dinkum\" then the game creates a \"data recorder\" \n"); 
  1054. printf("which appears in the beginning  of  the game.  The data \n"); 
  1055. printf("recorder acts like a tape recorder allowing the user to \n"); 
  1056. printf("save moves and play them back in the current  or  later \n"); 
  1057. printf("games.  The generated file is in ASCII format  and  can \n"); 
  1058. printf("be  edited  after  finishing  Dinkum.    Type  \"examine \n"); 
  1059. printf("recorder\" after having taken it and Dinkum will explain \n"); 
  1060. printf("how to use it.  This data  recorder  has  a  couple  of \n"); 
  1061. printf("important  limitations:   Unlike  most adventure games, \n"); 
  1062. printf("Dinkum is  dynamic,  viz.  the  game changes every time \n"); 
  1063. printf("you play it.  So if you record  a  script  for  a  game \n"); 
  1064. printf("which takes you to a room where you find a  weapon  and \n"); 
  1065. printf("then to another room where you find a monster, then the \n"); 
  1066. printf("next time you use  that script you may find the monster \n"); 
  1067. printf("where you  previously  found  the  weapon (leading to a \n"); 
  1068. printf("fairly short game). The other limitation  of  the  data \n"); 
  1069. printf("recorder is if you use the \"dinkum -s\" switch then  you \n"); 
  1070. printf("will  not  be  admitted  into  the  end  game  with the \n"); 
  1071. printf("consequence being that  \"winning\" Dinkum is impossible. \n"); 
  1072. printf("To win Dinkum you must  play  it  \"on your own\" without \n"); 
  1073. printf("the unfair advantage of script files and data recorders.\n\n");
  1074.  
  1075. /* keep the screen from scrolling */
  1076. #ifndef __TURBOC__
  1077. printf("         [Press RETURN or ENTER to continue]") ;
  1078. chr = getchar() ;
  1079. #endif
  1080.  
  1081. #ifdef __TURBOC__
  1082. printf("  [Press \"q\" to quit or any other key to continue]") ;
  1083. chr = getche() ;
  1084. printf("\r                                                        \r") ;
  1085. #endif
  1086.  
  1087. if ((chr == 'q')||(chr == 'Q')) exit (0) ;
  1088.  
  1089. printf("When corresponding please state the current version of\n") ;
  1090. printf("Dinkum which you are using.  Contributions and questions\n") ;
  1091. printf("about this program should be sent to the following address:\n\n") ;
  1092. printf("          E-mail address:     gary@sun.mech.uq.oz.au\n\n") ;
  1093. printf("          Postal address:     Gary A. Allen, Jr. \n");
  1094. printf("                              P.O. Box 13\n") ;       
  1095. printf("                              St. Lucia, Queensland  4067\n");
  1096. printf("                              Australia\n") ;
  1097.  
  1098. exit(0);
  1099. } /* ---- end of the "help" subroutine ---- */
  1100.  
  1101. #if (PROTOTYPE)
  1102. void cheater(void) 
  1103. #else
  1104. cheater() 
  1105. #endif
  1106. /*****************************************************/
  1107. /*                                                   */
  1108. /*  (c) Copyright 1992,   University of Queensland   */
  1109. /*        Program written by Gary A. Allen, Jr.      */
  1110. /*           Version:  Mk 1.0   9 December 1992      */
  1111. /*                                                   */
  1112. /*****************************************************/
  1113. {
  1114. printf("Rather than cheat at this game by using a disassembler, you\n");
  1115. printf("should send the author $150 and he'll gladly send you\n") ;
  1116. printf("the source code.  If you just want a clue, then send $20\n") ;
  1117. printf("with your question and he'll provide the answer.  You can find\n") ;
  1118. printf("the author's address by typing:  dinkum -h\n") ;
  1119.         exit(0) ;
  1120. } /* ---- end of the "cheater" subroutine ---- */
  1121.  
  1122. #if (PROTOTYPE)
  1123. int mover(int direction, int loc[3])
  1124. #else
  1125. int mover(direction,loc)
  1126. int direction, loc[3] ;
  1127. #endif
  1128. /*****************************************************/
  1129. /*                                                   */
  1130. /*  (c) Copyright 1992,   University of Queensland   */
  1131. /*        Program written by Gary A. Allen, Jr.      */
  1132. /*           Version:  Mk 1.0  17 December 1992      */
  1133. /*                                                   */
  1134. /*****************************************************/
  1135. {
  1136.  
  1137. #if (PROTOTYPE)
  1138. /* Function prototypes */
  1139. void long_descp(int), ender(int), boom(void) ;
  1140. #endif
  1141.  
  1142. /* see if this movement prohibits blasting caps */
  1143. if (((direction == V_u)||(direction == V_up)) &&
  1144.         ((loc[0] == R_manhole_1)||(loc[0] == R_manhole_2))) {
  1145.  
  1146.     if (Cap->Location == B_have) {
  1147. printf("As you were climbing up through the hole in the ceiling,\n");
  1148. printf("the blasting cap slipped from your grasp and fell to the\n") ;
  1149. printf("floor below where it detonated on impact.  The explosion\n") ;
  1150. printf("was deafening, but caused no damage.\n") ;
  1151.         carry_count-- ;
  1152.         carry_weight -= Cap->Weight ;
  1153.         Cap->Location = B_destroyed; 
  1154.     }
  1155.     else {
  1156.         if ((Dynamite->Location == B_have)&&(Dynamite->Type == Z_alias)) {
  1157.             boom() ;
  1158.  
  1159. printf("As you were climbing up through the hole in the ceiling,\n");
  1160. printf("the dynamite with the blasting cap inside slipped from\n") ;
  1161. printf("your grasp and fell to the floor below where it detonated\n") ;
  1162. printf("on impact.  At that point you literally became a human\n");
  1163. printf("cannon ball as the shock wave carried you up the vertical\n");
  1164. printf("passage and splattered you into protoplasmic jelly on the\n");
  1165. printf("ceiling above.\n") ; 
  1166.             ender(F_died) ;
  1167.         }
  1168.     }
  1169. } /* end of the cap/manhole block */
  1170.  
  1171. direction-- ;
  1172. if (room[loc[0]][direction] == R_WALL) {
  1173.     printf("You can't go that way. \n");
  1174.     return(FALSE) ;
  1175. }
  1176.  
  1177. /* save previous location */
  1178. loc[1] = loc[0] ;
  1179. loc[0] = room[loc[0]][direction] ;
  1180.  
  1181. /* See if player walked into a lethal room */
  1182. if (room[loc[0]][M_rm_type] == T_lethal) {
  1183.     long_descp(loc[0]) ;
  1184.     ender(F_died) ;
  1185. }
  1186. return(TRUE) ;
  1187. } /* --- end of the "mover" function --- */
  1188.  
  1189. #if (PROTOTYPE)
  1190. int yes_no(void)
  1191. #else
  1192. int yes_no()
  1193. #endif
  1194. /*****************************************************/
  1195. /*                                                   */
  1196. /*  (c) Copyright 1993,   University of Queensland   */
  1197. /*        Program written by Gary A. Allen, Jr.      */
  1198. /*           Version:  Mk 1.0  27 January 1993       */
  1199. /*                                                   */
  1200. /*****************************************************/
  1201. {
  1202.  
  1203. char chr ;
  1204.  
  1205. #if (PROTOTYPE)
  1206. /* Function prototypes ANSI C */
  1207. char getch(void), getche(void) ;
  1208.  
  1209. #else
  1210. /* Function prototypes K&R-C */
  1211. char getch(), getche() ;
  1212. #endif
  1213.  
  1214. for (;;) {
  1215.  
  1216. #ifndef __TURBOC__
  1217.     do {
  1218.         printf("(Answer:  Yes or No) ") ; 
  1219.     } while ('\n' == (chr = getchar())) ;
  1220.  
  1221.     while ('\n' != getchar()) ;
  1222. #endif
  1223.  
  1224. #ifdef __TURBOC__
  1225.     printf("\n") ;
  1226.     do {
  1227.         printf("(Answer:  Yes or No) ") ; 
  1228.     } while ('\n' == (chr = getch())) ;
  1229.     printf("\n") ;
  1230. #endif
  1231.  
  1232.     if (('n' == chr)||('N' == chr)||('y' == chr)||('Y' == chr)) break ;
  1233. } /* end of the infinite "for" loop */
  1234.  
  1235. if (('y' == chr)||('Y' == chr)) return(TRUE) ;
  1236. else return(FALSE) ;
  1237.  
  1238. } /* --- end of the "yes_no" function --- */
  1239.